package algorithm_optimal_solution.LinkedList;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

//删除链表中间节点：链表长度为空或1不需要删除；长度为2删除头节点；之后每增加两个节点中间节点后移一位。
public class RemoveMidNode {

    static class Node{
        private int value;
        private Node node;

        public Node(int value,Node node){
            this.value = value;
            this.node = node;
        }

        public int getValue() {
            return value;
        }

        public void setValue(int value) {
            this.value = value;
        }

        public Node getNode() {
            return node;
        }

        public void setNode(Node node){
            this.node = node;
        }
    }

    public void removeMidNode(Node head){
        if(head == null || head.getNode() == null){
            System.out.print(head.getValue());
            return;
        }
        if(head.getNode().getNode() == null){
            head = head.getNode();
            System.out.print(head.getValue());
            return;
        }
        Node currentNode = head;
        Node node = head.getNode().getNode();
        while(node.getNode() != null && node.getNode().getNode() != null){
            currentNode = currentNode.getNode();
            node = node.getNode().getNode();
        }
        currentNode.setNode(currentNode.getNode().getNode());
        StringBuilder sb = new StringBuilder();
        while(head != null){
            sb.append(head.getValue()).append(" ");
            head = head.getNode();
        }
        System.out.print(sb);
    }

    public static void main(String[] args)throws IOException {
        BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));
        String[] values = scanner.readLine().split(" ");
        int len = Integer.parseInt(values[0]);
        String[] numbers = scanner.readLine().split(" ");
        Node node = null;
        for(int i = len - 1;i >= 0;i--){
            node = new Node(Integer.parseInt(numbers[i]),node);
        }
        new RemoveMidNode().removeMidNode(node);
    }
}
